package org.jeecg.modules.wms.inventory.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.wms.inventory.entity.WmsInventory;
import org.jeecg.modules.wms.inventory.mapper.WmsInventoryMapper;
import org.jeecg.modules.wms.inventory.service.IWmsInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 库存表
 * @Author: jeecg-boot
 * @Date:   2025-10-31
 * @Version: V1.0
 */
@Service
public class WmsInventoryServiceImpl extends ServiceImpl<WmsInventoryMapper, WmsInventory> implements IWmsInventoryService {
    @Autowired
    private WmsInventoryMapper wmsInventoryMapper;

    @Override
    public WmsInventory getInventoryByUniqueKey(String productId, String locationCode, String batchNumber) {
        return  this.getOne(Wrappers.lambdaQuery(WmsInventory.class)
                .eq(WmsInventory::getProductId, productId)
                .eq(WmsInventory::getLocationCode, locationCode)
                .eq(ObjectUtil.isNotEmpty(batchNumber),WmsInventory::getBatchNumber, batchNumber)
                .isNull(ObjectUtil.isEmpty(batchNumber),WmsInventory::getBatchNumber)
        );
    }

    @Override
    public IPage<WmsInventory> pageList(Page<WmsInventory> page, WmsInventory wmsInventory) {
        Page<WmsInventory> pageList = wmsInventoryMapper.pageList(page,wmsInventory);
        List<WmsInventory> list = pageList.getRecords();

        return null;
    }
}
